<?php
defined('_JEXEC') or die('Restricted access');
require_once(JPATH_COMPONENT.DS.'data'.DS.'DAOPOISubCategory.php');
require_once(JPATH_COMPONENT.DS.'dominio'.DS.'DTOFactory.php');

class JDAOPOISubCategory implements DAOPOISubCategory{
	
	
	private function singleObjectQuery($query){
		$db =& JFactory::getDBO();
		$db->setQuery( $query );
		$row = $db->loadObject();
		if ($db->getErrorNum()) {
			echo $db->stderr();
			return false;
		}
		return $row;
	}
	private function multiObjectQuery($query){
		$db =& JFactory::getDBO();
		$db->setQuery( $query );
		$rows = $db->loadObjectList();
		if ($db->getErrorNum()) {
			echo $db->stderr();
			return false;
		}
		return $rows;
	}
	/* (non-PHPdoc)
	 * @see DAOPOISubCategory::getPOISubCategory()
	 */
	public function getPOISubCategory($id) {
		$row= $this->singleObjectQuery("SELECT * FROM #__sr_poisubcategories WHERE id=".$id);
		return DTOFactory::getInstance()->getDTOPOISubCategory($row);
	}
	
	public function getPOICatSubCats($id){
		$rows=$this->multiObjectQuery("SELECT * FROM #__sr_poisubcategories WHERE idCategory=".$id);
		return DTOFactory::getInstance()->getDTOPOISubCategories($rows);
	}

	
}


?>